﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Resources;

namespace VietThuongLMS
{
    public class ResourcesMgt
    {
        /// <summary>
        /// Set language for web page
        /// </summary>
        /// <param name="language"></param>
        public static void SetLocalize(string language)
        {
            string _language = string.IsNullOrEmpty(language) ? "vi-VN" : language;
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(_language);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(_language);
        }

        /// <summary>
        /// Set language for web page
        /// </summary>
        /// <param name="language">vi-VN, empty</param>
        /// <returns>ResourceManager</returns>
        public static ResourceManager LoadResource(string language)
        {
            string _language = string.IsNullOrEmpty(language) ? "vi-VN" : language;
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(_language);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(_language);
            return Resources.Global.ResourceManager;
        }

        /// <summary>
        ///  /// Set language for web page with vi-VN default language
        /// </summary>
        /// <returns></returns>
        public static ResourceManager LoadResource()
        {
            string _language = "vi-VN";
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(_language);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(_language);
            return Resources.Global.ResourceManager;
        }
    }
}